package com.ashlikun.zxing.view.style2

import android.content.Context
import android.util.AttributeSet
import android.view.View
import com.ashlikun.camera.scan.CameraScan
import com.ashlikun.zxing.ZxingBaseCameraScanView
import com.ashlikun.zxing.R
import com.ashlikun.zxing.view.full.ZxingStyleFullView
import com.google.zxing.Result

/**
 * @author　　: 李坤
 * 创建时间: 2022/5/2 22:54
 * 邮箱　　：496546144@qq.com
 *
 * 功能介绍：第二种样式扫描控件
 */

open class ZxingStyle2View @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, def: Int = 0) :
    ZxingStyleFullView(context, attributeSet, def) {
    val locView by lazy {
        findViewById<Style2LocationView>(R.id.locView)
    }

    override fun onCameraOpen(cameraScan: CameraScan<Result>) {
        super.onCameraOpen(cameraScan)
        locView.visibility = View.VISIBLE
        locView.startAnim()
    }

    override fun getLayoutId(): Int {
        return R.layout.xzxing_style2_floorview
    }

    override fun stopCamera() {
        super.stopCamera()
        locView.stopAnim()
        locView.visibility = View.GONE
    }
}